package com.haixiaoke.saas.cleaner.service.impl;

import com.haixiaoke.saas.cleaner.domain.InspectionProcessRecord;
import com.haixiaoke.saas.cleaner.domain.InspectionProcessRecordTree;
import com.haixiaoke.saas.cleaner.mapper.InspectionProcessRecordMapper;
import com.haixiaoke.saas.cleaner.service.IInspectionProcessRecordService;
import com.haixiaoke.saas.common.utils.DateUtils;
import com.haixiaoke.saas.common.utils.TreeUtil.TreeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 验房流程记录Service业务层处理
 *
 * @author xiaolong
 * @date 2024-05-10
 */
@Service
public class InspectionProcessRecordServiceImpl implements IInspectionProcessRecordService {
    @Autowired
    private InspectionProcessRecordMapper inspectionProcessRecordMapper;

    /**
     * 查询验房流程记录
     *
     * @param inspectionProcessId 验房流程记录主键
     * @return 验房流程记录
     */
    @Override
    public InspectionProcessRecord selectInspectionProcessRecordByInspectionProcessId(Long inspectionProcessId) {
        return inspectionProcessRecordMapper.selectInspectionProcessRecordByInspectionProcessId(inspectionProcessId);
    }

    /**
     * 查询验房流程记录列表
     *
     * @param inspectionProcessRecord 验房流程记录
     * @return 验房流程记录
     */
    @Override
    public List<InspectionProcessRecord> selectInspectionProcessRecordList(InspectionProcessRecord inspectionProcessRecord) {
        return inspectionProcessRecordMapper.selectInspectionProcessRecordList(inspectionProcessRecord);
    }

    /**
     * 新增验房流程记录
     *
     * @param inspectionProcessRecord 验房流程记录
     * @return 结果
     */
    @Override
    public int insertInspectionProcessRecord(InspectionProcessRecord inspectionProcessRecord) {
        inspectionProcessRecord.setCreateTime(DateUtils.getNowDate());
        return inspectionProcessRecordMapper.insertInspectionProcessRecord(inspectionProcessRecord);
    }

    /**
     * 修改验房流程记录
     *
     * @param inspectionProcessRecord 验房流程记录
     * @return 结果
     */
    @Override
    public int updateInspectionProcessRecord(InspectionProcessRecord inspectionProcessRecord) {
        inspectionProcessRecord.setUpdateTime(DateUtils.getNowDate());
        return inspectionProcessRecordMapper.updateInspectionProcessRecord(inspectionProcessRecord);
    }

    /**
     * 批量删除验房流程记录
     *
     * @param inspectionProcessIds 需要删除的验房流程记录主键
     * @return 结果
     */
    @Override
    public int deleteInspectionProcessRecordByInspectionProcessIds(Long[] inspectionProcessIds) {
        return inspectionProcessRecordMapper.deleteInspectionProcessRecordByInspectionProcessIds(inspectionProcessIds);
    }

    /**
     * 删除验房流程记录信息
     *
     * @param inspectionProcessId 验房流程记录主键
     * @return 结果
     */
    @Override
    public int deleteInspectionProcessRecordByInspectionProcessId(Long inspectionProcessId) {
        return inspectionProcessRecordMapper.deleteInspectionProcessRecordByInspectionProcessId(inspectionProcessId);
    }

    @Override
    public int insertInspectionProcessRecordList(List<InspectionProcessRecord> inspectionProcessRecordList) {
        return inspectionProcessRecordMapper.insertInspectionProcessRecordList(inspectionProcessRecordList);

    }

    @Override
    public List<InspectionProcessRecordTree> selectInspectionProcessRecordTree(InspectionProcessRecord inspectionProcessRecord) {
        List<InspectionProcessRecordTree> inspectionProcessRecordTreeList = inspectionProcessRecordMapper.selectInspectionProcessRecordTree(inspectionProcessRecord);
        return TreeUtil.generateTree(inspectionProcessRecordTreeList);
    }

    @Override
    public int updateInspectionProcessRecordByHouseInspectionIds(InspectionProcessRecord inspectionProcessRecord) {
        return inspectionProcessRecordMapper.updateInspectionProcessRecordByHouseInspectionIds(inspectionProcessRecord);
    }

    @Override
    public int updateInspectionProcessRecordList(List<InspectionProcessRecord> inspectionProcessRecordList) {
        return inspectionProcessRecordMapper.updateInspectionProcessRecordList(inspectionProcessRecordList);
    }

    @Override
    public List<InspectionProcessRecord> selectInspectionProcessRecordByHouseInspectionIds(InspectionProcessRecord inspectionProcessRecord) {
        return inspectionProcessRecordMapper.selectInspectionProcessRecordByHouseInspectionIds(inspectionProcessRecord);
    }

    @Override
    public List<InspectionProcessRecord> selectInspectionProcessRecordByHouseInspectionIdsAndParentId(InspectionProcessRecord inspectionProcessRecord) {
        return inspectionProcessRecordMapper.selectInspectionProcessRecordByHouseInspectionIdsAndParentId(inspectionProcessRecord);
    }

}
